<!--# include virtual="/admin/common/html/header.html"-->
<body>
<div class="page-container">
	<form  class="form form-horizontal" id="form-guidance">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>工程名字：</label>
			<div class="formControls skin-minimal col-xs-6 col-sm-6">
				<input type="text" name="costName"  id="costName" class="input-text"  placeholder="工程名字">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>工程分类：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="hidden" name="catalogId"  id="catalogId">
				<input type="text" name="catalogName"  id="catalogName" class="input-text"  placeholder="工程分类">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>工程地点：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="address" name="address"  placeholder="工程地点">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>总建筑面积：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="totalArea" name="totalArea"  placeholder="总建筑面积">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>地上建筑面积：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="overArea" name="overArea"  placeholder="地上建筑面积">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>地下建筑面积：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="underArea" name="underArea"  placeholder="地下建筑面积">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>建筑总高度：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="projectHeight" name="projectHeight"  placeholder="建筑总高度">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>首层高度：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="firstHeight" name="firstHeight"  placeholder="首层高度">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>二层高度：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="secondHeight" name="secondHeight"  placeholder="二层高度">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>标准层高度：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="standardHeight" name="standardHeight"  placeholder="标准层高度">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>顶层高度：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="topHeight" name="topHeight"  placeholder="顶层高度">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>其他非标准层高度：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="otherHeight" name="otherHeight"  placeholder="其他非标准层高度">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>建筑总层数（层）：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="totalFloor" name="totalFloor"  placeholder="建筑总层数（层）">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>地上层数：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="overFloor" name="overFloor"  placeholder="地上层数">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>地下层数：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" id="underFloor" name="underFloor"  placeholder="地下层数">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button  class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i>保存并提交</button>
				<button class="btn btn-default radius" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>
<!--# include virtual="/admin/common/html/_footer.html"-->
<script>
	var explainEditor;
$(function(){
	var  costId= GetQueryString("costId");
    if(costId){
    	$.post("/guidance_service/front/data/get.do",{"costId":costId},function(result){
			if(result.resultCode == 200){
				$("input[name='costName']").val(result.data.costName);
				$("input[name='catalogId']").val(result.data.catalogId);
				$("input[name='catalogId']").val(result.data.catalogId);
				$("input[name='address']").val(result.data.address);
				$("input[name='totalArea']").val(result.data.totalArea);
				$("input[name='overArea']").val(result.data.overArea);
				$("input[name='underArea']").val(result.data.underArea);
				$("input[name='projectHeight']").val(result.data.projectHeight);
				$("input[name='firstHeight']").val(result.data.firstHeight);
				$("input[name='secondHeight']").val(result.data.secondHeight);
				$("input[name='standardHeight']").val(result.data.standardHeight);
				$("input[name='topHeight']").val(result.data.topHeight);
				$("input[name='otherHeight']").val(result.data.otherHeight);
				$("input[name='totalFloor']").val(result.data.totalFloor);
				$("input[name='overFloor']").val(result.data.overFloor);
				$("input[name='underFloor']").val(result.data.underFloor);
				
		 	}else{
	 			layer.msg("页面请求出错,系统将自动刷新，请稍后再试！",{icon:2,time:2000},function(){
		 	    	window.history.back();
	 			});
		 	}
		});
    }
});
var guidanceNamePreL,guidanceNamePreR;
function setNameTime(str){
	var newR=str.split("-")[0]+"年"+str.split("-")[1]+"月份";
	var newStr=$("#guidanceName").val();
	if((!newStr)||(!guidanceNamePreR)||newStr.search(guidanceNamePreR)<0){
		if((!newStr)||(!guidanceNamePreL)||newStr.search(guidanceNamePreL)<0){
			newStr=(guidanceNamePreL?(guidanceNamePreL+newR):newR)+"信息价";
		}else{
			newStr=newStr.replace(guidanceNamePreL,guidanceNamePreL+newR);
		}
	}else{
		newStr=newStr.replace(guidanceNamePreR,newR);
	}
	$("#guidanceName").val(newStr);
	guidanceNamePreR=newR;
}
$(function(){		
	$(document).on("change","#county",function(){
		var newL=$("#county").find("option:selected").text();
		var newStr=$("#guidanceName").val();
		if((!newStr)||(!guidanceNamePreL)||newStr.search(guidanceNamePreL)<0){
			if((!newStr)||(!guidanceNamePreR)||newStr.search(guidanceNamePreR)<0){
				newStr=(guidanceNamePreR?(newL+guidanceNamePreR):newL)+"信息价";
			}else{
				newStr=newStr.replace(guidanceNamePreR,newL+guidanceNamePreR);
			}
		}else{
			newStr=newStr.replace(guidanceNamePreL,newL);
		}
		$("#guidanceName").val(newStr);
		guidanceNamePreL=newL;
	});
	$("#form-guidance").validate({		//表单验证
		rules:{
			area:{required:true,},
			explains:{required:true,},
			guidanceName:{required:true,},
			major:{required:true,},
//			explains:{required:true,},
		},
		debug:true,
		onkeyup:false,
		focusCleanup:false,
		success:"valid",
		submitHandler:function(form){
			var data =$(form).serialize();
			data.costId=GetQueryString("costId");
            var action=GetQueryString("costId")?"/guidance_service/front/data/update.do":"/guidance_service/front/data/add.do";
			$.post(action,data,function(result){
		 		if(result.resultCode ==200){
		 			layer.msg(result.message,{icon:1,time:2000},function(){
		 				window.location.href="/admin/modules/datashare/info/infoList.html?costId="+result.data.costId;
		 			});
		 		}else{
		 			layer.msg(result.message,{icon:2,time:2000});
		 		}
			});
		}
	});
});
$("#explains").keyup(function(){
	$("#explains").Huitextarealength({
		minlength:0,
		maxlength:5000
	});	
});

</script>
</body>
</html>
